#include "thread.h"
//#include <pthread.h>
#include <iostream>
#include <signal.h>
#include <boost/lexical_cast.hpp>
#include "pcap++/PcapOffline.h"
#include "pcap++/PcapLive.h"
#include "pcap++/config.h"
#include <pcap++/Packet.h>
#include <pcap++/DataLink.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <map>
#include <list>
#include <queue>


//:static void *process_thread(void* this_class);
static void* start_thread(void* obj);


ThreadProcess::ThreadProcess(std::string const& name) : m_name(name), m_running(true)
{
	pthread_create(&m_thread, 0, &start_thread, this);
}

ThreadProcess::~ThreadProcess()
{
}
void ThreadProcess::stopProcess()
{
	std::cout << "StopProces=" << m_name << std::endl;
	m_running = false;
}

static void* start_thread(void* obj)
{
	std::cout << "Process started=" << reinterpret_cast<ThreadProcess *>(obj)->name() << std::endl;
	while(reinterpret_cast<ThreadProcess *>(obj)->running())
	{
		reinterpret_cast<ThreadProcess *>(obj)->process();
	}
	std::cout << "Process terminated=" << reinterpret_cast<ThreadProcess *>(obj)->name() << std::endl;

	return false;
}

